Refactor view factory registration#32
Open
kaitj wants to merge 1 commit into
Open
Conversation
7bc3a02 to
d4cc736
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## enh/plugins #32 +/- ##
===============================================
- Coverage 99.72% 99.72% -0.01%
===============================================
Files 19 18 -1
Lines 730 727 -3
===============================================
- Hits 728 725 -3
Misses 2 2 ☔ View full report in Codecov by Sentry. |
d4cc736 to
d0cb720
Compare
Repurposes the code from plugins.py (now deprecated) to register the different view factories. To maintain compatability, added a "view_name" attribute which is the name that gets added to the registry. Additionally, the import code tries to import from the path if a search path is provided, otherwise will search the sys.path for existing modules with the "niftyone_" prefix.
d0cb720 to
3e92f99
Compare
Contributor
Author
|
Oops - accidently closed this when I deleted the branch. Reopening. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The plugin discovery gave me some inspiration to refactor how we initially implemented the view registration. Some primary changes with this PR
factory.py, allowing for calling a single function instead of importing every single view in the__init__.py. Also reworked theregisterfunction to be called as part ofregister_viewsrather than being used as a decorator for each function.sys.pathor from a user-defined plugin directory. The plugin registration is called as part of theparticipantworkflow.view_name(maybe temporary?), that will register a view factory using said name. If one is not provided, theview_namewould be equivalent to the class name.Edit: Will need to refactor this slightly such that the old register functionality is brought back rather than the automatic registration if view is a child of the base class.